package com.csd.action.team;

import com.csd.helper.ActionResult;
import com.csd.helper.SessionManager;
import com.csd.pojo.Student;
import com.csd.pojo.Team;
import com.csd.serviceImpl.TeamService;

/**
 * 
 * 保存团队信息
 * @author csd
 * @version 1.0
 * 
 * <br> 修订时间：2009-12-17
 * <br> 修改原因：创建文件
 * <br> 修改人：刘世彬
 * 
 * <br> 
 * 
 */
public class TeamSaveAction {
	/** 团队名称 */
	private String name ;
	/**团队介绍*/
	private String introduction;
	/**团队队长ID*/
	private String leaderID;
	
	private String projectTypeID ;
	


	public String getProjectTypeID() {
		return projectTypeID;
	}

	public void setProjectTypeID(String projectTypeID) {
		this.projectTypeID = projectTypeID;
	}

	public String getLeaderID() {
		return leaderID;
	}

	public void setLeaderID(String leaderID) {
		this.leaderID = leaderID;
	}

	private TeamService service;

	public TeamService getService() {
		return service;
	}

	public void setService(TeamService service) 
	{
		this.service = service;
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public String execute() throws Exception 
	{
		String result = ActionResult.fail;
		
		//查询当前登录的团队 
		Team team = service.getTeam();
		
		team.setIntroduction(this.introduction);
		team.setName(this.name);
		
		Student leader = new Student();
		if(leaderID!=null)
		{
			leader.setId(Integer.parseInt(leaderID));
			team.setLeader(leader);	
		}

		if(service.updateTeam(team))
		{
			//根据工程 ID导航 
				if(projectTypeID.equals("null"))
				{
					result="submit";
				}
				else
				{
					if(leaderID != null && leaderID.length()>0)
					{
						result = "projectApply"; 
					}
					else
					{												
						result = ActionResult.success;
					}
				}
		}
		return result;
	}
}
